import java.util.Arrays;

public class OddBeforeAndAfter {
    public static void sort(int[] arr) {
        int left = 0;
        int right = arr.length-1;
        while(left < right) {
            if(arr[left]%2 != 0) {
                left++;
            } else if(arr[right]%2==0) {
                right--;
            } else {
                int a = arr[left];
                arr[left] = arr[right];
                arr[right] = a;
                left++;
                right--;
            }
        }
    }
    public static void main(String[] args) {
        int[] arr = {1,2,3,4,5,6,7,8,9};
        sort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
